package indi.zn.commons.properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil{
	
	/**
	 * 不带 /
	 * @param clazz
	 * @param path
	 * @return
	 * @throws IOException
	 */
	public static Properties getFromClassPath(Class clazz,String path) throws IOException{
		
		Properties pro=new Properties();
		
		 InputStream in = clazz.getResourceAsStream(path);
	
		pro.load(in);
		
		return pro;
	
	}
	
	public static Properties getFromFilePath(String filepath) throws FileNotFoundException, IOException{
		
	Properties pro=new Properties();
	pro.load(new FileInputStream(filepath));
	
		return pro;
	
	}

 /**
  * 带 /
  * @param classpath
  * @return
  * @throws IOException
  */

   public static Properties getFromSysClassPath(String classpath) throws IOException{
	
	Properties pro=new Properties();
	pro.load(PropertiesUtil.class.getClassLoader().getSystemResourceAsStream(classpath));


	return pro;

}

   public static void main(String[] args) throws IOException {
	
	//   Properties pro= getFromClassPath(PropertiesUtil.class, "/org/zn/commons/httpconnection/status/StatusHandlerStateMapping.properties") ;
	   
	  Properties pro=  getFromSysClassPath("/org/zn/commons/httpconnection/status/StatusHandlerStateMapping.properties");
	   

	  System.out.println(pro);
	   
	   
	   
}
    

}
